<?php

/**
 * Created by PhpStorm.
 * User: Yieong
 * Date: 16/3/22
 * Time: 上午11:58
 */
class RechargeService extends Service{

    public static function header($params){
        $header = array(
            'RecDate'       => array('text' => '日期'),
            'SID'           => array('text' => '服'),
            'PayUser'       => array('text' => '充值玩家', 'rule' => 'numeric'),
            'PayCount'      => array('text' => '充值次数', 'rule' => 'numeric'),
            'PayMoney'      => array('text' => '充值金额', 'rule' => 'numeric'),
            'PayGold'       => array('text' => '获得元宝数', 'rule' => 'numeric'),
            'FirstPayUser'  => array('text' => '首充玩家', 'rule' => 'numeric'),
            'FirstPayCount' => array('text' => '首充次数', 'rule' => 'numeric'),
            'FirstPayMoney' => array('text' => '首充金额', 'rule' => 'numeric'),
            'FirstPayGold'  => array('text' => '首充获得元宝数', 'rule' => 'numeric'),
            'CumPayUser'    => array('text' => '累计充值玩家', 'rule' => 'numeric'),
            'CumPayCount'   => array('text' => '累计充值次数', 'rule' => 'numeric'),
            'CumPayMoney'   => array('text' => '累计充值金额', 'rule' => 'numeric'),
            'CumPayGold'    => array('text' => '累计获得元宝数', 'rule' => 'numeric'),
            'PresentGold'   => array('text' => '充值赠送元宝', 'rule' => 'numeric'),
            'CumPresentGold'=> array('text' => '累计充值赠送元宝', 'rule' => 'numeric'),
            'UsedGold'      => array('text' => '元宝消耗数', 'rule' => 'numeric'),
            'CumUsedGold'   => array('text' => '累计元宝消耗数', 'rule' => 'numeric'),
        );
        if($params['server'] == 'ALL'){
        	unset($header['SID']);
        }
        return $header;
    }

    public static function data($params){

        if(PubFunc::checkEmpty($params, array('g', 'server'))) return array();

        $modGamePayment = new ModGamePayment();

        $data = $modGamePayment->getData($params);
        
        $new_data = array();
        foreach ($data as $key=>$val){
        	if($params['server'] != 'ALL'){
        		$new_data[$val['RecDate']]['SID'] = $val['SID'];
        	}
        	$new_data[$val['RecDate']]['RecDate'] = $val['RecDate'];
        	$new_data[$val['RecDate']]['PayUser'] += $val['PayUser'];
        	$new_data[$val['RecDate']]['PayCount'] += $val['PayCount'];
        	$new_data[$val['RecDate']]['PayMoney'] += $val['PayMoney'];
        	$new_data[$val['RecDate']]['PayGold'] += $val['PayGold'];
        	 
        	$new_data[$val['RecDate']]['FirstPayUser'] += $val['FirstPayUser'];
        	$new_data[$val['RecDate']]['FirstPayCount'] += $val['FirstPayCount'];
        	$new_data[$val['RecDate']]['FirstPayMoney'] += $val['FirstPayMoney'];
        	$new_data[$val['RecDate']]['FirstPayGold'] += $val['FirstPayGold'];
        	 
        	$new_data[$val['RecDate']]['CumPayUser'] += $val['CumPayUser'];
        	$new_data[$val['RecDate']]['CumPayCount'] += $val['CumPayCount'];
        	$new_data[$val['RecDate']]['CumPayMoney'] += $val['CumPayMoney'];
        	$new_data[$val['RecDate']]['CumPayGold'] += $val['CumPayGold'];
        	$new_data[$val['RecDate']]['UsedGold'] += $val['UsedGold'];
        	$new_data[$val['RecDate']]['CumUsedGold'] += $val['CumUsedGold'];
        	$new_data[$val['RecDate']]['PresentGold'] += $val['PresentGold'];
        	$new_data[$val['RecDate']]['CumPresentGold'] += $val['CumPresentGold'];
        	
        	$new_data[$val['RecDate']]['R1'] += $val['R1'];
        	$new_data[$val['RecDate']]['R30'] += $val['R30'];
        	$new_data[$val['RecDate']]['R98'] += $val['R98'];
        	$new_data[$val['RecDate']]['R198'] += $val['R198'];
        	$new_data[$val['RecDate']]['R328'] += $val['R328'];
        	$new_data[$val['RecDate']]['R648'] += $val['R648'];
        }

        foreach($new_data as &$v){
            $v['Ltv7ARPPU']      = number_format($v['Ltv7PayMoney'] / $v['Ltv7PayUser'], 2, '.', '');
            $v['Ltv14ARPPU']     = number_format($v['Ltv14PayMoney'] / $v['Ltv14PayUser'], 2, '.', '');
            $v['Ltv30ARPPU']     = number_format($v['Ltv30PayMoney'] / $v['Ltv30PayUser'], 2, '.', '');

            $v['PayUser'] = empty($v['PayUser'])? 0: $v['PayUser'];
            $v['PayCount'] = empty($v['PayCount'])? 0: $v['PayCount'];
            $v['PayMoney'] = empty($v['PayMoney'])? 0: $v['PayMoney'];
            $v['PayGold'] = empty($v['PayGold'])? 0: $v['PayGold'];
            $v['FirstPayUser'] = empty($v['FirstPayUser'])? 0: $v['FirstPayUser'];
            $v['FirstPayCount'] = empty($v['FirstPayCount'])? 0: $v['FirstPayCount'];
            $v['FirstPayMoney'] = empty($v['FirstPayMoney'])? 0: $v['FirstPayMoney'];
            $v['FirstPayGold'] = empty($v['FirstPayGold'])? 0: $v['FirstPayGold'];
        }
        unset($v);

        return $new_data;
    }

    public static function chart($data, $params){

        $chartData = array();

        $sort = new PubMultiSort('PayMoney', 'desc');
        $data = $sort->getResult($data);
        $key = 'RecDate';

        foreach($data as $v){
            if(!empty($v[$key])){
                $chartData[PubFunc::t('付款金额')][$v[$key]] = $v['PayMoney'];
                $chartData[PubFunc::t('付款人数')][$v[$key]] = intval($v['PayUser']);
            }
        }

        return array(
            'data'   => $chartData,
            'config' => array(
                'xAxis' => array('axisLabel' => array('interval' => 0, 'rotate' => 25)),
                'series' => array(
                    PubFunc::t('付款金额') => array( 'type' => 'bar', 'barWidth' => 20),
                    PubFunc::t('付款人数') => array( 'yAxisIndex' => 1 )
                ),
            )
        );
    }

    public static function ltvHeader($params){
        $header = array(
            'RecDate'       => array('text' => '日期'),
            'SID'           => array('text' => '服'),
            'RoleUser'      => array('text' => '创建角色数', 'rule' => 'numeric'),

        );
        $day = array(0,1,2,3,4,5,6,7,14,30);
        foreach ($day as $key=>$val){
        	$header['Ltv'.$val.'PayCol'] = array(
                'text'      => '创角'.$val.'天有过充值',
                'include'   => array(
                    'Ltv'.$val.'PayMoney_R'  => array('text' => '金额', 'rule' => 'numeric'),
                    'Ltv'.$val.'PayUser_R'   => array('text' => '人数', 'rule' => 'numeric'),
                    'Ltv'.$val.'ARPPU'     => array('text' => 'ARPPU', 'rule' => 'numeric'),
                	'Ltv'.$val.'LTV'       => array('text' => 'LTV', 'rule' => 'numeric'),
                )
            );
        }
        if($params['server'] == 'ALL'){
        	unset($header['SID']);
        }
        return $header;
    }

    public static function ltvData($params){

        if(PubFunc::checkEmpty($params, array('g', 'server'))) return array();

        $modGamePayment = new ModGamePayment();

        $data = $modGamePayment->getLtvData($params);
        
        $new_data = array();
        $day = array(0,1,2,3,4,5,6,7,14,30);
        foreach ($data as $key=>$val){
        	if($params['server'] != 'ALL'){
        		$new_data[$val['RecDate']]['SID'] = $val['SID'];
        	}
        	$new_data[$val['RecDate']]['RecDate'] = $val['RecDate'];

        	$new_data[$val['RecDate']]['RegUser'] += $val['RegUser'];
        	$new_data[$val['RecDate']]['RoleUser'] += $val['RoleUser'];
        	
        	$new_data[$val['RecDate']]['PayMoney'] += $val['PayMoney'];
        	$new_data[$val['RecDate']]['PayGold'] += $val['PayGold'];
        	
        	foreach ($day as $k=>$v){
        		$new_data[$val['RecDate']]['Ltv'.$v.'PayUser'] += $val['Ltv'.$v.'PayUser'];
        		$new_data[$val['RecDate']]['Ltv'.$v.'PayMoney'] += $val['Ltv'.$v.'PayMoney'];
        		$new_data[$val['RecDate']]['Ltv'.$v.'PayUser_R'] += $val['Ltv'.$v.'PayUser_R'];
        		$new_data[$val['RecDate']]['Ltv'.$v.'PayMoney_R'] += $val['Ltv'.$v.'PayMoney_R'];       		
        	}
        }

        foreach($new_data as &$v){
        	foreach ($day as $key=>$val){
        		$v['Ltv'.$val.'ARPPU']      = number_format($v['Ltv'.$val.'PayMoney_R'] / $v['Ltv'.$val.'PayUser_R'], 2, '.', '');
        		$v['Ltv'.$val.'LTV']        = number_format($v['Ltv'.$val.'PayMoney_R'] / $v['RoleUser'], 2, '.', '');
        	}
           
        }
        unset($v);

        return $new_data;
    }

    public static function userHeader($params){
        $header = array(
            'RecDate'       => array('text' => '日期'),
            'SID'           => array('text' => '服'),
            'DAU'           => array('text' => '活跃用户', 'rule' => 'numeric'),
            'PayCount'      => array('text' => '充值次数', 'rule' => 'numeric'),
            'PayUser'       => array('text' => '充值玩家数', 'rule' => 'numeric'),
            'FirstPayUser'  => array('text' => '新用户充值数', 'rule' => 'numeric'),
            'OldPayUser'    => array('text' => '老用户充值数', 'rule' => 'numeric'),
            'PayRate'       => array('text' => '付费率', 'rule' => 'percent'),
            'PayMoney'      => array('text' => '付费总额', 'rule' => 'numeric'),
            'AvgPayMoney'   => array('text' => '平均付费', 'rule' => 'numeric'),
            'R1'            => array('text' => '1档充值次数', 'rule' => 'numeric'),
            'R1Rate'        => array('text' => '1档充值次数占比', 'rule' => 'percent'),
            'R30'           => array('text' => '2档充值次数', 'rule' => 'numeric'),
            'R30Rate'       => array('text' => '2档充值次数占比', 'rule' => 'percent'),
            'R98'           => array('text' => '3档充值次数', 'rule' => 'numeric'),
            'R98Rate'       => array('text' => '3档充值次数占比', 'rule' => 'percent'),
            'R198'          => array('text' => '4档充值次数', 'rule' => 'numeric'),
            'R198Rate'      => array('text' => '4档充值次数占比', 'rule' => 'percent'),
            'R328'          => array('text' => '5档充值次数', 'rule' => 'numeric'),
            'R328Rate'      => array('text' => '5档充值次数占比', 'rule' => 'percent'),
            'R648'          => array('text' => '6档充值次数', 'rule' => 'numeric'),
            'R648Rate'      => array('text' => '6档充值次数占比', 'rule' => 'percent'),
        );
        return $header;
    }

    public static function userData($params){
        if(PubFunc::checkEmpty($params, array('g', 'server'))) return array();

        $modGamePayment = new ModGamePayment();

        $data = $modGamePayment->getUserData($params);

        foreach($data as &$v){
            if(empty($v['PayCount'])) $v['PayCount'] = 0;
            if(empty($v['PayUser'])) $v['PayUser'] = 0;
            if(empty($v['FirstPayUser'])) $v['FirstPayUser'] = 0;
            if(empty($v['PayMoney'])) $v['PayMoney'] = '0.00';
            if(empty($v['DAU'])) $v['DAU'] = 0;

            $v['OldPayUser'] = $v['PayUser'] - $v['FirstPayUser'];

            if(!empty($v['DAU'])){
                $v['PayRate']       = number_format($v['PayUser'] / $v['DAU'] * 100, 2) . '%';
                $v['AvgPayMoney']   = number_format($v['PayMoney'] / $v['DAU'], 2);
            }else{
                $v['PayRate'] = '0.00%';
                $v['AvgPayMoney']   = '0.00';
            }

            if(!empty($v['PayCount'])) {
                foreach (array('R1', 'R30', 'R98', 'R198', 'R328', 'R648') as $rv) {
                    $v[$rv.'Rate'] = number_format($v[$rv] / $v['PayCount'] * 100, 2) . '%';
                }
            }else{
                foreach (array('R1', 'R30', 'R98', 'R198', 'R328', 'R648') as $rv) {
                    $v[$rv.'Rate'] = '0.00%';
                }
            }
        }
        unset($v);

        return $data;
    }

    public static function retainHeader($params){
        $header = array(
            'RecDate'       => array('text' => '日期'),
            'SID'           => array('text' => '服'),
            'PayUser'       => array('text' => '付费用户数', 'rule' => 'numeric'),
            'Retain'        => array(
                'text'      => '付费玩家留存数',
                'include'   => array(
                    'Remain1Day'   => array('text' => '1日', 'rule' => 'numeric'),
                    'Remain3Day'   => array('text' => '3日', 'rule' => 'numeric'),
                    'Remain7Day'   => array('text' => '7日', 'rule' => 'numeric'),
                    'Remain14Day'  => array('text' => '14日', 'rule' => 'numeric'),
                    'Remain30Day'  => array('text' => '30日', 'rule' => 'numeric'),
                    'Remain60Day'  => array('text' => '60日', 'rule' => 'numeric'),
                )
            ),
            'PayRate'        => array(
                'text'      => '付费玩家再付费数',
                'include'   => array(
                    'RemainPay1Day'  => array('text' => '1日', 'rule' => 'numeric'),
                    'RemainPay3Day'  => array('text' => '3日', 'rule' => 'numeric'),
                    'RemainPay7Day'  => array('text' => '7日', 'rule' => 'numeric'),
                    'RemainPay14Day' => array('text' => '14日', 'rule' => 'numeric'),
                    'RemainPay30Day' => array('text' => '30日', 'rule' => 'numeric'),
                    'RemainPay60Day' => array('text' => '60日', 'rule' => 'numeric'),
                )
            ),
        );
        return $header;
    }

    public static function retainData($params){

        if(PubFunc::checkEmpty($params, array('g', 'server'))) return array();

        $modGamePayment = new ModGamePayment();
        $data = $modGamePayment->getRetainData($params);

        $day = array(1,3,7,14,30,60);
        foreach($data as &$v){
            foreach($day as $dv){
                $v["Remain{$dv}Day"] .= ' <span style="color: green;">('.number_format($v["Remain{$dv}Day"] / $v['PayUser'] * 100, 2) . '%)</span>';
                $v["RemainPay{$dv}Day"] .= ' <span style="color: green;">('.number_format($v["RemainPay{$dv}Day"] / $v['PayUser'] * 100, 2) . '%)</span>';
            }
        }
        unset($v);

        return $data;
    }
    

    public static function gradeHeader($params){
    	$header = array(
    			'RecDate'       => array('text' => '日期'),
    			'GameSrc'       => array('text' => '游戏'),
    			'SID'           => array('text' => '游戏服'),
    			'Level'         => array('text' => '充值等级'),
    			'PayUser'       => array('text' => '充值用户数'),
    			'PayCount'      => array('text' => '充值次数'),
    			'PayMoney'      => array('text' => '充值金额'),
    			'PayGold'       => array('text' => '充值元宝'),
    		
    	);
    	if($params['server'] == 'ALL'){
    		unset($header['SID']);
    	}
    	return $header;
    }
    
    public static function gradeData($params){
    
    	if(PubFunc::checkEmpty($params, array('g', 'server'))) return array();
    
    	$modGamePayment = new ModGamePayment();
    
    	$data = $modGamePayment->getGradeData($params);
    	
    	if($params['time_start'] == $params['time_end']){
    		$date = $params['time_start'];
    	}else{
    		$date = date('Y.m.d', strtotime($params['time_start'])).'~'.date('Y.m.d', strtotime($params['time_end']));
    	}
    
    	foreach($data as &$v){
    		$v['RecDate']           = $date;
    
    	}
    	unset($v);
    
    	return $data;
    }
    
    public static function gradeCountchart($data, $params){
    
    	$chartData = array();
    	foreach($data as $v){
    		if(!empty($v['Level'])){
    			$chartData[PubFunc::t('等级充值次数分布')][$v['Level']] = $v['PayCount'];
    		}
    	}
    
    	return array(
    			'data'   => $chartData,
    			'config' => array(
    					'title'  => '等级充值次数分布',
    					'xAxis' => array('axisLabel' => array('interval' => 0, 'rotate' => 25),'name'=>'充值等级'),
    					'yAxis' => array('name'=>'充值次数'),
    					'series' => array(
    							PubFunc::t('充值等级') => array( 'barWidth' => 20),
    					),
    			)
    	);
    }
    
    public static function gradeGoldchart($data, $params){
    	$chartData = array();
    	foreach($data as $v){
    		if(!empty($v['Level'])){
    			$chartData[PubFunc::t('等级充值元宝分布')][$v['Level']] = $v['PayGold'];
    		}
    	}
    	
    	return array(
    			'data'   => $chartData,
    			'config' => array(
    					'title'  => '等级充值元宝分布',
    					'xAxis' => array('axisLabel' => array('interval' => 0, 'rotate' => 25),'name'=>'充值等级'),
    					'yAxis' => array('name'=>'充值元宝'),
    					'series' => array(
    							PubFunc::t('充值等级') => array( 'barWidth' => 20),
    					),
    			)
    	);
    }
    
    
    public static function intervalHeader($params){
    	$header = array(
    			'ctext'         => array('text' => '统计'),
    			'i_1_49'        => array('text' => '[1,49]', 'rule' => 'numeric'),
    			'i_50_99'       => array('text' => '[50,99]', 'rule' => 'numeric'),
    			'i_100_199'     => array('text' => '[100,199]', 'rule' => 'numeric'),
    			'i_200_499'     => array('text' => '[200,499]', 'rule' => 'numeric'),
    			'i_500_999'     => array('text' => '[500,999]', 'rule' => 'numeric'),
    			'i_1000_1999'   => array('text' => '[1000,1999]', 'rule' => 'numeric'),
    			'i_2000_4999'   => array('text' => '[2000,4999]', 'rule' => 'numeric'),
    			'i_5000_9999'   => array('text' => '[5000,9999]', 'rule' => 'numeric'),
    			'i_10000'     => array('text' => '[10000,+]', 'rule' => 'numeric'),
    	);
    	return $header;
    }
    
    public static function intervalData($params){
    	if(PubFunc::checkEmpty($params, array('g', 'server'))) return array();

        $modGamePayment = new ModGamePayment();

        $data = $modGamePayment->getIntervalData($params);
        
        $data_d = array();
        foreach ($data as $key=>$val){
        	$data_d[$val['RecDate']][] = $val;
        }
        
        $result = array();
        foreach ($data_d as $key=>$val){
        	$money_1_49 = $user_1_49 = 0;
        	$money_50_99 = $user_50_99 = 0;
        	$money_100_199 = $user_100_199 = 0;
        	$money_200_499 = $user_200_499 = 0;
        	$money_500_999 = $user_500_999 = 0;
        	$money_1000_1999 = $user_1000_1999 = 0;
        	$money_2000_4999 = $user_2000_4999 = 0;
        	$money_5000_9999 = $user_5000_9999 = 0;
        	$money_10000 = $user_10000= 0;
        	$all_money = 0;
        	foreach ($val as $k=>$v){
        		$all_money += $v['PayMoney'];
        		if($v['PayMoney'] >= 1 && $v['PayMoney'] <= 49){
        			$money_1_49 += $v['PayMoney'];
        			$user_1_49 += $v['PayUser'];
        		}
        		if($v['PayMoney'] >= 50 && $v['PayMoney'] <= 99){
        			$money_50_99 += $v['PayMoney'];
        			$user_50_99 += $v['PayUser'];
        		}
        		if($v['PayMoney'] >= 100 && $v['PayMoney'] <= 199){
        			$money_100_199 += $v['PayMoney'];
        			$user_100_199 += $v['PayUser'];
        		}
        		if($v['PayMoney'] >= 200 && $v['PayMoney'] <= 499){
        			$money_200_499 += $v['PayMoney'];
        			$user_200_499 += $v['PayUser'];
        		}
        		if($v['PayMoney'] >= 500 && $v['PayMoney'] <= 999){
        			$money_500_999 += $v['PayMoney'];
        			$user_500_999 += $v['PayUser'];
        		}
        		if($v['PayMoney'] >= 1000 && $v['PayMoney'] <= 1999){
        			$money_1000_1999 += $v['PayMoney'];
        			$user_1000_1999 += $v['PayUser'];
        		}
        		if($v['PayMoney'] >= 2000 && $v['PayMoney'] <= 4999){
        			$money_2000_4999 += $v['PayMoney'];
        			$user_2000_4999 += $v['PayUser'];
        		}
        		if($v['PayMoney'] >= 5000 && $v['PayMoney'] <= 9999){
        			$money_5000_9999 += $v['PayMoney'];
        			$user_5000_9999 += $v['PayUser'];
        		}
        		if($v['PayMoney'] >= 10000){
        			$money_10000 += $v['PayMoney'];
        			$user_10000 += $v['PayUser'];
        		}
        	}
        	
        	$rate_1_49 = number_format($money_1_49 / $all_money * 100, 2).'%';
        	$rate_50_99 = number_format($money_50_99 / $all_money * 100, 2).'%';
        	$rate_100_199 = number_format($money_100_199 / $all_money * 100, 2).'%';
        	$rate_200_499 = number_format($money_200_499 / $all_money * 100, 2).'%';
        	$rate_500_999 = number_format($money_500_999 / $all_money * 100, 2).'%';
        	$rate_1000_1999 = number_format($money_1000_1999 / $all_money * 100, 2).'%';
        	$rate_2000_4999 = number_format($money_2000_4999 / $all_money * 100, 2).'%';
        	$rate_5000_9999 = number_format($money_5000_9999 / $all_money * 100, 2).'%';
        	$rate_10000 = number_format($money_10000 / $all_money * 100, 2).'%';
        	
        	$data_n[0] = array('ctext' => '充值人数','i_1_49'=>$user_1_49,'i_50_99'=>$user_50_99,'i_100_199'=>$user_100_199,'i_200_499'=>$user_200_499,'i_500_999'=>$user_500_999,'i_1000_1999'=>$user_1000_1999,'i_2000_4999'=>$user_2000_4999,'i_5000_9999'=>$user_5000_9999,'i_10000'=>$user_10000);
        	$data_n[1] = array('ctext' => '充值金额','i_1_49'=>$money_1_49,'i_50_99'=>$money_50_99,'i_100_199'=>$money_100_199,'i_200_499'=>$money_200_499,'i_500_999'=>$money_500_999,'i_1000_1999'=>$money_1000_1999,'i_2000_4999'=>$money_2000_4999,'i_5000_9999'=>$money_5000_9999,'i_10000'=>$money_10000);
        	$data_n[2] = array('ctext' => '所占比例','i_1_49'=>$rate_1_49,'i_50_99'=>$rate_50_99,'i_100_199'=>$rate_100_199,'i_200_499'=>$rate_200_499,'i_500_999'=>$rate_500_999,'i_1000_1999'=>$rate_1000_1999,'i_2000_4999'=>$rate_2000_4999,'i_5000_9999'=>$rate_5000_9999,'i_10000'=>$rate_10000);
        	$result[$key] = $data_n;
        }
        
        $begin  = strtotime($params['time_start']);
        $end    = strtotime($params['time_end']) + 86400;
        for(;$begin<$end;$begin+=86400){
        	$day = date('Y-m-d', $begin);
        	if(!$result[$day]){
        		$data_n[0] = array('ctext' => '充值人数','i_1_49'=>0,'i_50_99'=>0,'i_100_199'=>0,'i_200_499'=>0,'i_500_999'=>0,'i_1000_1999'=>0,'i_2000_4999'=>0,'i_5000_9999'=>0,'i_10000'=>0);
        		$data_n[1] = array('ctext' => '充值金额','i_1_49'=>0,'i_50_99'=>0,'i_100_199'=>0,'i_200_499'=>0,'i_500_999'=>0,'i_1000_1999'=>0,'i_2000_4999'=>0,'i_5000_9999'=>0,'i_10000'=>0);
        		$data_n[2] = array('ctext' => '所占比例','i_1_49'=>0,'i_50_99'=>0,'i_100_199'=>0,'i_200_499'=>0,'i_500_999'=>0,'i_1000_1999'=>0,'i_2000_4999'=>0,'i_5000_9999'=>0,'i_10000'=>0);
        		$result[$day]= $data_n;
        	}
        }
        krsort($result);
        return $result;
    }
    
    
}